home *** CD-ROM | disk | FTP | other *** search
- /*
- File: RefCounted.h
-
- Contains: C++ mix-in class for doing reference counting.
-
- Written by: Troy Gaul
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
- */
-
- #ifndef _REFCOUNTED_
- #define _REFCOUNTED_
-
- //------------------------------------------------------------------------------
- // MRefCounted
- //------------------------------------------------------------------------------
-
- class MRefCounted {
-
- public:
-
- MRefCounted();
-
- virtual ~MRefCounted();
-
- virtual void Acquire();
-
- virtual void Release();
-
- virtual ODSLong GetRefCount();
-
- private:
-
- ODSLong fRefCount;
-
- };
-
- //------------------------------------------------------------------------------
- // TempRefCounted
- //------------------------------------------------------------------------------
-
- class TempRefCounted : Destructo {
-
- public:
-
- TempRefCounted(MRefCounted*);
-
- virtual ~TempRefCounted();
-
- MRefCounted* operator=(MRefCounted*);
-
- void DontRelease();
-
- private:
-
- // disallow these:
- TempRefCounted();
- TempRefCounted(const TempRefCounted&);
- void operator=(const TempRefCounted&);
-
- MRefCounted* fObject;
-
- };
-
- //------------------------------------------------------------------------------
- // Debugging functions
- //------------------------------------------------------------------------------
- #if ODDebug
- void CheckRefCountedObjects();
- #endif
-
-
- #endif